{{template "member/top.html" .}}
<div class="m-b-md"> <h3 class="m-b-none">{{msg . "Password"}}</h3></div>
<div class="row">
<div class="col-sm-8">
	<form id="formData">
		<section class="panel panel-default">
			<div class="panel-body">
				<div class="alert alert-danger" id="pwdMsg" style="display: none"></div>
				<div class="form-group">
					<label class="control-label" for="oldPwd">{{msg . "oldPassword"}}</label>
					 <input type="password" class="form-control" id="oldPwd" name="oldPwd"
				    	data-rules='[
					    	{rule: "required", msg: "inputPassword"}
				    	]'
				    	data-msg_target="#pwdMsg"
				    />
				</div>
				<div class="form-group"> 
					<label class="control-label" for="pwd">{{msg . "newPassword"}}</label>
					<input type="password" class="form-control" id="pwd" name="pwd"
					    data-rules='[
					    	{rule: "required", msg: "inputNewPassword"},
					    	{rule: "password", msg: "errorPassword"}
				    	]'
				    	data-msg_target="#pwdMsg"
				    >
					<div class="form-tips">{{msg . "passwordTips"}}</div>
				</div>
				<div class="form-group"> 
					<label class="control-label" for="pwd2">{{msg . "password2"}}</label>
					 <input type="password" class="form-control" id="pwd2" name="pwd2"
					    data-rules='[
					    	{rule: "required", msg: "inputPassword2"},
					    	{rule: "equalTo", data:"#pwd", msg: "confirmPassword"}
				    	]'
				    	data-msg_target="#pwdMsg"
				    />
				</div>
			</div>
			<footer class="panel-footer text-right bg-light lter">
			    <button type="submit" id="pwdBtn" class="btn btn-success">{{msg . "submit"}}</button>
			</footer>
		</section>
	</form>
</div>

</div>

{{template "member/footer.html" .}}
<script>
$(function() {
// 修改密码
var updatePwdVd = new vd.init("#formData");
$("#pwdBtn").click(function(e) {
	e.preventDefault();
	if(!updatePwdVd.valid()) {
		return;
	}
	var oldPwd = $("#oldPwd").val();
	var pwd = $("#pwd").val();
	post("/user/updatePwd", {oldPwd: oldPwd, pwd: pwd}, function(e) {
		if(e.Ok) {
			showAlert("#pwdMsg", getMsg("updatePasswordSuccess"), "success");
		} else {
			showAlert("#pwdMsg", e.Msg, "danger");
		}
	}, "#pwdBtn");
});
});
</script>

{{template "member/end.html" .}}
